(function() { // configuration for intercept var configuration = { brands: { natwest: { // regex expression to match. This can be a RegExp type, or an object with up to 2 keys: {pageName: RegExp, url: RegExp} // To match a pageName this must be an object with the pageName key and RegExp value, if only a RegExp value is given then it's assumed to be for a URL regexp: /\.natwest(\.com|\/)/, theme: { logo: 'https://insights.natwest.com/surveys/images/6QU67V/nw_secondary_horizontal_rgb_neg_crop.png', privacyPolicy: 'https://personal.natwest.com/personal/privacy-policy.html', color: 'rgb(90, 40, 125);' }, surveyDomain: 'https://insights.natwest.com', prepopFields: { // can be function (will be given the brand and URL input parameters) or number, string BRAND: '0' } }, rbs: { regexp: /rbs\.co\.uk/, theme: { logo: 'https://insights.rbs.co.uk/surveys/images/6QU67V/rb_horizontal_stacked_rgb_neg_crop.png', privacyPolicy: 'https://personal.rbs.co.uk/personal/privacy-policy.html', color: 'rgb(90, 40, 125);' }, surveyDomain: 'https://insights.rbs.co.uk', prepopFields: { BRAND: '1' } }, ulster: { regexp: /\.ulsterbank\.co\.uk/, theme: { logo: 'https://insights.ulsterbank.com/surveys/images/6QU67V/ub_horizontal_rgb_neg_crop.png', privacyPolicy: 'https://digital.ulsterbank.co.uk/globals/privacy.html', color: 'rgb(90, 40, 125);' }, surveyDomain: 'https://insights.ulsterbank.com', prepopFields: { BRAND: '2' } } }, URLs: [ { regexp: /(\/personal|)\/current\-accounts\/existing-customers\.html/, dwellTime: 30000, prepopFields: { JOURNEY: 'Manage your account (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-Brochurewear-CurrentAccounts-Existing' } }, { regexp: /(\/personal|)\/current\-accounts\/existing\-customers\/select\-account\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Manage your account (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-CurrentAccounts-Existing-SelectAccount' } }, { regexp: /(\/personal|)\/credit\-cards\.html/, dwellTime: 30000, prepopFields: { JOURNEY: 'Browse and apply (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-Brochureware-CreditCards' } }, { regexp: /(\/personal|)\/credit\-cards\/the\-natwest\-credit\-card\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Browse and apply (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-Brochureware-CreditCards-NWCreditCard' } }, { // inactive regexp: /(\/personal|)\/banking\-with\-natwest\.html/, dwellTime: 30000, prepopFields: { JOURNEY: 'Ways to Bank (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-WaystoBank' } }, { regexp: /(\/personal|)\/banking-with-natwest\/other-ways-to-bank-with-natwest\/natwest-telephone-banking\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-WaystoBank-Telephony' } }, { regexp: /(\/personal|)\/banking-with-natwest\/register-for-online-banking\.html/, dwellTime: 30000, prepopFields: { JOURNEY: 'Ways to Bank (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-WaystoBank-OnlineBanking' } }, { // inactive regexp: /(\/personal|)\/ways\-to\-bank\/understanding\-your\-statement\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-WaystoBank-UnderstandStatement' } }, { regexp: /(\/personal|)\/support\-centre\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Help and support (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-SupportCentre' } }, { regexp: /\/business\/support\-centre\/manage\-your\-account\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Help and support (Business / Commercial Banking)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-SupportCentre-ManageAccount' } }, { regexp: /\/business\/support\-centre\/manage\-your\-account\/manage\-your\-signatories\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Help and support (Business / Commercial Banking)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-SupportCentre-ManageAccount-Signatories' } }, { regexp: /\/business\/business\-services\/entrepreneur\-accelerator\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Help and support (Business / Commercial Banking)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-EntrepreneurAccelerator' } }, { regexp: /\/business\/ways\-to\-bank\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Business/Commercial)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-WaystoBank-MainPage' } }, { regexp: /\/business\/ways\-to\-bank\/mobile-banking\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Business/Commercial)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-WaystoBank-Mobile' } }, { regexp: /\/business\/ways\-to\-bank\/online-banking\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Business/Commercial)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-WaystoBank-Online' } }, { regexp: /\/business\/ways\-to\-bank\/digital-banking\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Business/Commercial)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-WaystoBank-Digital' } }, { regexp: /\/business\/ways\-to\-bank\/bankline\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Business/Commercial)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-WaystoBank-Bankline' } }, { regexp: /\/business\/ways\-to\-bank\/bankline-mobile\.html/, dwellTime: 50000, prepopFields: { JOURNEY: 'Ways to Bank (Business/Commercial)', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-WaystoBank-Bankline-Mobile' } } /*{ regexp: /\/business\/support(\-centre|)\/service\-status\/coronavirus\.html/, dwellTime: 50000, prepopFields: { JOURNEY: '[CORONAVIRUS] Business / Commercial Coronavirus page', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-SupprtCentre-CoronavirusSupportPage' } },*/ /*{ regexp: /\/business\/support(\-centre|)\/service\-status\/coronavirus\/government\-scheme\.html/, dwellTime: 50000, prepopFields: { JOURNEY: '[CORONAVIRUS] Business / Commercial Coronavirus gov scheme page', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-SupprtCentre-GovCoronavirusScheme' } },*/ /*{ regexp: {pageName: /^OLAF\:PERSONAL\>Mortgage\>(Rbs|Nwb|Ubn)mortgagepaymentholidays\>ID12[568]\>Step2\>Confirmation$/}, // pageName dwellTime: 30000, prepopFields: { JOURNEY: '[CORONAVIRUS] Mortgage repayment holiday form (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-Mortgage-MortgageRepaymentHoliday' }, ignoreCookie: true // ignore the quarantine cookie for this route/URL/pageName },*/ /*{ regexp: {pageName: /^OLAF\:PERSONAL\>Managecreditlimit\>(ID733|ID(732|693))\>Step3\>Manageyourcreditlimit$/}, // pageName dwellTime: 7000, prepopFields: { JOURNEY: '[CORONAVIRUS] Changing your credit card limit form (Personal Banking)', CUSTOMER_TYPE: 'Personal', WEBPAGE: 'Personal-CreditCards-ChangingCreditCardLimit' }, ignoreCookie: true },*/ /*{ regexp: /\/business\/support\-centre\/service\-status\/coronavirus\/coronavirus-business-interruption-loan-scheme\.html/, dwellTime: 50000, prepopFields: { JOURNEY: '[CORONAVIRUS] Business / Commercial Coronavirus CBILS page', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-SupprtCentre-CBILS' } },*/ /*{ regexp: /coronavirus\-business\.natwest\.com\/supporting\-you/, dwellTime: 50000, prepopFields: { JOURNEY: '[CORONAVIRUS] Business / Commercial Coronavirus Hub Supporting You page', CUSTOMER_TYPE: 'Business/Commercial', WEBPAGE: 'Business-CoronavirusHub-SupportingYoupage' } }*/ ], prepopFields: { // prepop fields for all respondents. can be function (will be given the brand and URL input parameters) or number, string BROWSER: getBrowserInfo, SCREEN: getScreenSize, BROWSER_RESOLUTION: getBrowserSize, OS: getOS, DEVICE_TYPE: getDeviceType, DOMAIN: function() { return window.location.origin; }, PARTICIPANT_SEGMENT: function() {return 0;}, // return the pageName if exists, else just return current URL (origin + pathname only, no hash values or parameters) URL: function(brand, URL) { return (URL.regexp.pageName && typeof window.s === 'object' && s.pageName) || window.location.origin + window.location.pathname; } }, surveyPath: '/cgi-bin/qwebcorporate.dll?idx=458337', quarantineExpiresIfYes: 28, // number of days quarantine cookie expires if respondent accepts survey quarantineExpiresIfNo: 28, // number of days quarantine cookie expires if respondent declines survey quarantineCookieName: 'mcxYourExpWebSurveyQuarantine' // name of quarantine cookie }; var DEBUG = true; // debug/verbose flag // intercept script. Do not modify anything below this line // set triggers var brand = null; var URL = null; var surveyURL = ''; try { if (document.readyState === 'complete') { main(); } else { document.addEventListener('DOMContentLoaded', main); } function main() { brand = getBrand(); URL = getURL(); // check triggers debugMessage('has Brand: ' + (brand? true : false), 'has URL: ' + (URL? true : false)); if (DEBUG) { window.imInterceptTriggers = { brand: brand === null || brand === undefined? '???' : brand.prepopFields.BRAND, JOURNEY: (URL && URL.prepopFields && URL.prepopFields.JOURNEY) || '???', CUSTOMER_TYPE: (URL && URL.prepopFields && URL.prepopFields.CUSTOMER_TYPE) || '???', WEBPAGE: (URL && URL.prepopFields && URL.prepopFields.WEBPAGE) || '???', } } if (brand === null || URL === null) { debugMessage('Survey triggers not satisfied, no survey will be shown'); return; } // check for quarantine cookie if (hasCookie(configuration.quarantineCookieName) && !URL.ignoreCookie) { debugMessage('Quarantine cookie found. Survey will not be shown'); return; } // prepare survey URL surveyURL = brand.surveyDomain + configuration.surveyPath; addURLParameters(configuration.prepopFields); addURLParameters(brand.prepopFields); addURLParameters(URL.prepopFields); // show invite if (DEBUG) URL.dwellTime = 1; debugMessage('Showing invite modal in ' + (URL.dwellTime || 0) + ' milliseconds'); setTimeout(function() { openInvite(); }, URL.dwellTime || 1); // set up message listener to listen for close message from survey window.addEventListener('message', function(e) { if (brand && e.origin == brand.surveyDomain && e.data == 'mcx close popup') closeSurvey(); }, false); } // trigger field functions function getBrand() { for (var brand in configuration.brands) { // check regexp in each brand if (checkRegExp(configuration.brands[brand].regexp)) return configuration.brands[brand]; } return null; } function getURL() { for (var URL in configuration.URLs) { // check regexp in each brand if (checkRegExp(configuration.URLs[URL].regexp)) return configuration.URLs[URL]; } return null; } // check the regexp variable, applicable to all regexp variables in the config function checkRegExp(regexp) { if ( typeof regexp === 'object' && ( regexp instanceof RegExp || // default RegExp for URL only regexp.URL instanceof RegExp && (regexp = regexp.URL) // object with 'URL' key ) ) { return regexp.test(window.location.href); } else if (typeof regexp === 'object' && regexp.pageName instanceof RegExp) { // check pageName if (typeof window.s === 'object' && typeof window.s.pageName === 'string') { // pageName is stored in global Adobe variable s return regexp.pageName.test(window.s.pageName); } } return null; } // modal functions function openInvite() { // add CSS var mcx_intercept_stylesheetMain = document.createElement("style"); //mcx_intercept_stylesheetMain.innerHTML = '@import url(\'https://fonts.googleapis.com/css?family=Muli:300,400,600,700,800&display=swap\');\r\n #mcxText8 {\r\n color: #1D7B8A;\r\n text-decoration: none;\r\n}\r\n#mcxText8:hover {\r\n text-decoration: underline;\r\n}\r\n #mcxContainer {\r\n background: rgba(0, 0, 0, 0.3);\r\n z-index: 9999;\r\n height: 100%;\r\n width: 100%;\r\n position: fixed;\r\n top: 0px;\r\n left: 0px;\r\n overflow: hidden;\r\n text-align: left;\r\n border: 0px;\r\n font-style: inherit;\r\n font-variant: inherit;\r\n font-stretch: inherit;\r\n vertical-align: baseline;\r\n cursor: default;\r\n margin: 0px;\r\n padding: 0px;\r\n font-weight: 400;\r\n text-indent: 0px;\r\n text-shadow: none;\r\n line-height: 1.4;\r\n font-size: 100% !important;\r\n font-family: "Open Sans", Helvetica, sans-serif !important;\r\n float: none !important;\r\n \r\n}\r\n\r\n#mcxInvitation {\r\n background: rgba(0, 0, 0, 0.3);\r\n z-index: 9999;\r\n height: 100%;\r\n width: 100%;\r\n position: fixed;\r\n top: 0px;\r\n left: 0px;\r\n overflow: hidden;\r\n text-align: left;\r\n border: 0px;\r\n font-style: inherit;\r\n font-variant: inherit;\r\n font-stretch: inherit;\r\n vertical-align: baseline;\r\n cursor: default;\r\n margin: 0px;\r\n padding: 0px;\r\n font-weight: 400;\r\n text-indent: 0px;\r\n text-shadow: none;\r\n line-height: 1.4;\r\n font-size: 100% !important;\r\n font-family: "Open Sans", Helvetica, sans-serif !important;\r\n float: none !important;\r\n}\r\n\r\n#mcxModal1 {\r\n font: 400 1rem / 140% Muli, Arial, Helvetica, sans-serif !important;\r\n position: relative;\r\n top: 10%;\r\n margin: 0 auto;\r\n max-width: 590px;\r\n background: white;\r\n max-height: 80%;\r\n overflow:scroll;\r\n}\r\n #mcxModal1::-webkit-scrollbar {display:none;}\r\n#mcxModalHeader {\r\n font-size: 1.125em;\r\n text-align: right;\r\n color: #fff;\r\n padding: 10px;\r\n}\r\n\r\n#mcxModalBody {\r\n padding: 20px;\r\n}\r\n\r\n#mcxText1 {\r\n font-weight: bold;\r\n font-size: 1.250em;\r\n}\r\n\r\n#mcxAcceptSurvey {\r\n font: inherit;\r\n background: #cdcdcd;\r\n border: 1px solid #666666;\r\n color: #000;\r\n display: inline-block;\r\n padding: 5px 10px;\r\n cursor: pointer;\r\n margin: 10px 20px 20px 0; \r\n}\r\n\r\n#mcxDeclineSurvey {\r\n font: inherit;\r\n background: #cdcdcd;\r\n border: 1px solid #666666;\r\n color: #000;\r\n display: inline-block;\r\n padding: 5px 10px;\r\n cursor: pointer; \r\n margin: 10px 0; \r\n}\r\n\r\n#mcxLogo {\r\n max-width: 200px;\r\n display: block;\r\n}\r\n img#mcxLogo[src*="ulsterbank"] {padding: 20px;} \r\n#mcxModal {\r\ndisplay:flex; flex-direction: column; position: relative;\r\n margin: 0 auto;\r\n top: 5%;\r\n max-width: 590px;\r\n background: white;\r\n height: 85%;\r\n overflow: scroll;\r\n overflow: -moz-scrollbars-none; -webkit-overflow-scrolling: touch;\r\n overflow-x: auto;\r\n}\r\n #mcxModal::-webkit-scrollbar { display: none; visibility: hidden;}\r\n#mcxModal iframe {\r\n flex: 1; width: 100%!important;\r\n\r\n overflow:auto;\r\n margin-top: 28px;\r\n float: left; \r\n position: relative; \r\n}\r\n\r\n#mcxClose {\r\nfont: 400 1rem / 140% Muli, Arial, Helvetica, sans-serif !important;\r\n position: absolute;\r\n right: 0;\r\n margin: 0 auto;\r\n text-align: right;\r\n color: white;\r\n padding: 5px;\r\n cursor: pointer; left:0px;\r\n}\r\n\r\n@media screen and (max-width:380px) {\r\n #mcxInvitation {\r\n background: rgba(0, 0, 0, 0.3);\r\n z-index: 9999;\r\n height: 100%;\r\n width: 100%;\r\n position: fixed;\r\n top: 0px;\r\n left: 0px;\r\n overflow: hidden;\r\n text-align: left;\r\n border: 0px;\r\n vertical-align: baseline;\r\n cursor: default;\r\n margin: 0px;\r\n padding: 0px;\r\n text-indent: 0px;\r\n text-shadow: none;\r\n line-height: 1.4;\r\n float: none !important;\r\n }\r\n #mcxModal1 {\r\n position: relative;\r\n top: 40px;\r\n max-width: 590px;\r\n background: white;\r\n margin: 0 auto;\r\n max-height: 90%;\r\n}\r\n #mcxModalHeader {\r\n text-align: right;\r\n color: #fff;\r\n padding: 10px;\r\n }\r\n #mcxModalBody {\r\n padding: 10px 20px;\r\n }\r\n #mcxText1 {\r\n font-weight: bold;\r\n }\r\n #mcxText8 {\r\n color: #1D7B8A;\r\n margin: 10px 0px;\r\n text-align: right;\r\n }\r\n #mcxAcceptSurvey {\r\n background: #cdcdcd;\r\n border: 1px solid #666666;\r\n color: #000;\r\n padding: 3px 9px;\r\n font-size: 1.000em;\r\n cursor: pointer\r\n }\r\n #mcxDeclineSurvey {\r\n background: #cdcdcd;\r\n border: 1px solid #666666;\r\n color: #000;\r\n padding: 3px 9px;\r\n font-size: 1.000em;\r\n cursor: pointer\r\n }\r\n #mcxLogo {\r\n max-height: 58px;\r\n max-width: 200px;\r\n display: block\r\n }\r\n}\r\n\r\n@media screen and (max-width:600px) {\r\n #mcxModal {\r\n position: relative;\r\n top: 10%;\r\n margin: 0 auto;\r\n max-width: 590px;\r\n background: white;\r\n }\r\n iframe {\r\n width: 590px;\r\n height: 100%!important;\r\n }\r\n #mcxClose {\r\nfont: 400 1rem / 140% Muli, Arial, Helvetica, sans-serif !important;\r\n position: absolute;\r\n max-width: 590px;\r\n margin: 0 auto;\r\n text-align: right;\r\n color: white;\r\n padding: 5px;\r\n cursor: pointer\r\n }\r\n} @media screen and (max-width: 365px) {#mcxModal, #mcxModal1 {top: 0; height: 100%; max-height: 100%;} #mcxModalHeader p {margin: 0}} @media screen and (max-width: 400px) {#mcxModal {top:0; height: 100%}}'; mcx_intercept_stylesheetMain.innerHTML = ` #mcxInvitation, #mcxContainer { background: rgba(0, 0, 0, 0.5); z-index: 9999; height: 100%; width: 100%; position: fixed; top: 0px; left: 0px; overflow: hidden; cursor: default; margin: 0px; padding: 0px; } #mcxModal1, #mcxModal { outline-offset: 2px; position: relative; top: 10%; margin: 0 auto; max-width: 590px; background: white; border-radius: 16px; } #mcxModal1 *, #mcxModal * { outline-offset: 2px; } #mcxModalHeader { padding: 12px 8px; border-radius: 16px 16px 0 0; background: rgb(90, 40, 125); } #mcxModalHeader > p, #mcxClose { font-family: "RNHouseSans-Regular","RNHouseSansRegular", sans-serif; color: #fff; font-size: 18px; font-weight: normal; margin: 0; position: absolute; width: fit-content; right: 20px; top: 20px; text-decoration: underline; cursor: pointer; } #mcxLogo { margin: 14px 12px; max-height: 56px; display: block; } #mcxModalBody { padding: 0 20px; display: flex; flex-direction: column; } #mcxText1 { font-family: "RNHouseSans-Bold","RNHouseSansBold", sans-serif; margin: 22px 0 0 0; font-weight: bold; font-size: 20px; color: rgb(51, 51, 51); letter-spacing: -0.1px; } #mcxText2 { font-family: "RNHouseSans-Regular","RNHouseSansRegular", sans-serif; margin: 16px 0 0 0; color: rgb(100, 96, 104); font-size: 16px; font-weight: normal; line-height: 22px; } #mcxModalButtons { display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; margin: 27px 0 0 0; flex-wrap: wrap; } #mcxAcceptSurvey { font-family: "RNHouseSans-Bold","RNHouseSansBold", sans-serif; font-size: 16px; border: transparent; background: rgb(94, 16, 177); border-radius: 27px; color: #fff; padding: 16px 42px; cursor: pointer; margin: 0; font-weight: bold; letter-spacing: -0.1px; line-height: 22px; margin-right: 20px; white-space: nowrap; margin-bottom: 25px; } #mcxDeclineSurvey { font-family: "RNHouseSans-Bold","RNHouseSansBold", sans-serif; font-size: 16px; border: solid 2px rgb(94, 16, 177); border-radius: 27px; background: #fff; color: rgb(94, 16, 177); padding: 16px 42px; cursor: pointer; margin: 0; font-weight: bold; letter-spacing: -0.1px; line-height: 22px; white-space: nowrap; margin-bottom: 25px; } #mcxText5 { font-family: "RNHouseSans-Regular","RNHouseSansRegular", sans-serif; color: rgb(100, 96, 104); font-size: 16px; font-weight: normal; line-height: 22px; margin: 0; } #mcxModalFooter { margin: 24px -8px 14px 0; display: flex; flex-direction: row; justify-content: end; } #mcxText8 { font-family: "RNHouseSans-Regular","RNHouseSansRegular", sans-serif; margin: 14px 12px; color: rgb(94, 16, 177); font-size: 16px; font-weight: normal; height: 20px; letter-spacing: 0px; text-decoration: underline; } #mcxModal { display: flex; flex-direction: column; position: relative; top: 5%; max-width: 590px; background: rgb(90, 40, 125); height: 85%; overflow: hidden; overflow-x: auto; padding-bottom: 16px; } #mcxModal iframe { width: 100%; height: 100%; } #mcxSurveyClose { height: 44px; background-color: rgb(90, 40, 125); } #mcxClose { right: 10px; top: 0; margin: 10px; width: fit-content; } @media screen and (max-width:380px) { #mcxInvitation, #mcxContainer { z-index: 9999; height: 100%; width: 100%; position: fixed; top: 0px; left: 0px; text-align: left; border: 0px; vertical-align: baseline; cursor: default; margin: 0px; padding: 0px; float: none !important; } #mcxModal1, #mcxModal { top: 0; position: absolute; bottom: 0; border-radius: 0; left: 0; right: 0; } #mcxModal { height: auto; } #mcxModalHeader { border-radius: 0; } } `; document.head.appendChild(mcx_intercept_stylesheetMain); var inviteHTML = // old // ' '; ``; var inviteDiv = document.createElement('div'); inviteDiv.setAttribute('id', 'mcxInvitation'); inviteDiv.innerHTML = inviteHTML; document.body.insertBefore(inviteDiv, document.body.firstChild); var acceptButton = document.getElementById('mcxAcceptSurvey'); handleButtonEvent(acceptButton, acceptSurvey); var declineButton = document.getElementById('mcxDeclineSurvey'); handleButtonEvent(declineButton, declineSurvey); var closeButton = document.querySelector('#mcxModalHeader > p'); handleButtonEvent(closeButton, declineSurvey); } function closeInvite() { var el = document.getElementById("mcxInvitation"); if (el) { document.body.removeChild(el); debugMessage("Survey invite Closed"); } } function openSurvey() { var containerHTML = // old // '
' + // '
Close [x]
' + // '
'; ``; container = document.createElement('div'); container.setAttribute("id", 'mcxContainer'); container.innerHTML = containerHTML; document.body.appendChild(container); var closeButton = document.getElementById('mcxClose'); handleButtonEvent(closeButton, declineSurvey); } function closeSurvey() { var el = document.getElementById("mcxContainer"); if (el) { document.body.removeChild(el); debugMessage("Survey Closed"); } } function handleButtonEvent(button, callback) { var _callback = function(event) { if (event.type == 'click' || event.which == 13 || event.keyCode == 13) { callback() } } if (button && button.addEventListener) { button.addEventListener('click', _callback); button.addEventListener('keyup', _callback); } } // clicking the accept button on the modal runs this function acceptSurvey() { // set quarantine cookie var expiryDate = new Date(); expiryDate.setDate(expiryDate.getDate() + configuration.quarantineExpiresIfYes); !URL.ignoreCookie && setCookie(configuration.quarantineCookieName, true, expiryDate); // launch the survey debugMessage('survey accepted'); closeInvite(); openSurvey(); debugMessage('survey opened'); } // clicking the decline button or close button on the modal runs this function declineSurvey(event) { // set quarantine cookie var expiryDate = new Date(); expiryDate.setDate(expiryDate.getDate() + configuration.quarantineExpiresIfNo); !URL.ignoreCookie && setCookie(configuration.quarantineCookieName, true, expiryDate); // close survey debugMessage('survey declined'); closeInvite(); closeSurvey(); debugMessage('survey closed'); } // other helpers function setCookie(name, value, expiryDate) { if ((document.cookie = 'test').indexOf.call(document.cookie, 'test') == -1) { // cannot set cookie debugMessage('unable to access cookies. Quarantine cookie will not be set'); } else { var cookiePath = window.location.pathname.match(/(.+)\//); cookiePath = cookiePath && cookiePath.length > 1 ? cookiePath[1] : '/'; if (typeof expiryDate === 'function') expiryDate = expiryDate.toUTCString(); // save cookie document.cookie = name + '=' + value + '; expires=' + expiryDate + '; path=' + cookiePath; debugMessage('quarantine cookie created'); } } function hasCookie(name) { var cookieSearch = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); debugMessage((cookieSearch ? 'has' : 'does not have') + ' cookie "' + name + '"'); return cookieSearch ? true : false; } function addURLParameters(parameters) { for (var key in parameters) { var parameterValue = parameters[key]; if (parameters[key] && {}.toString.call(parameters[key]) === '[object Function]') { // run function if function parameterValue = parameters[key](brand, URL); } debugMessage('adding URL parameter', key, '=', parameterValue); surveyURL += (/\?.+=/.test(surveyURL) ? '&' : '?') + key + '=' + encodeURIComponent(parameterValue); } } function debugMessage() { if (!DEBUG) return; var args = Array.prototype.slice.call(arguments); args.unshift('MCX intercept DEBUG: '); Function.prototype.apply.call(console.log, console, args); } } catch (e) { console.error('MCX intercept error: ', e); } // Analytics functions // Get OS function getOS() { var clientStrings = [ // OS strings may need updating as new versions are released { s: 'Windows 10', r: /(Windows 10.0|Windows NT 10.0)/ }, { s: 'Windows 8.1', r: /(Windows 8.1|Windows NT 6.3)/ }, { s: 'Windows 8', r: /(Windows 8|Windows NT 6.2)/ }, { s: 'Windows 7', r: /(Windows 7|Windows NT 6.1)/ }, { s: 'Windows Vista', r: /Windows NT 6.0/ }, { s: 'Windows Server 2003', r: /Windows NT 5.2/ }, { s: 'Windows XP', r: /(Windows NT 5.1|Windows XP)/ }, { s: 'Windows 2000', r: /(Windows NT 5.0|Windows 2000)/ }, { s: 'Windows ME', r: /(Win 9x 4.90|Windows ME)/ }, { s: 'Windows 98', r: /(Windows 98|Win98)/ }, { s: 'Windows 95', r: /(Windows 95|Win95|Windows_95)/ }, { s: 'Windows NT 4.0', r: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/ }, { s: 'Windows CE', r: /Windows CE/ }, { s: 'Windows 3.11', r: /Win16/ }, { s: 'Android', r: /Android/ }, { s: 'Open BSD', r: /OpenBSD/ }, { s: 'Sun OS', r: /SunOS/ }, { s: 'Linux', r: /(Linux|X11)/ }, { s: 'iOS', r: /(iPhone|iPad|iPod)/ }, { s: 'Mac OS X', r: /Mac OS X/ }, { s: 'Mac OS', r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ }, { s: 'QNX', r: /QNX/ }, { s: 'UNIX', r: /UNIX/ }, { s: 'BeOS', r: /BeOS/ }, { s: 'OS/2', r: /OS\/2/ }, { s: 'Search Bot', r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ } ]; for (var client in clientStrings) { if (window.navigator && clientStrings[client].r.test(window.navigator.userAgent)) { return clientStrings[client].s; } } return 'Others'; } // get device type function getDeviceType() { // returns the key of a device property in deviceSizes, as a string var deviceSizes = { // must cover all positive numbers Mobile: { min: 0, max: 600 }, Tablet: { min: 601, max: 1280 }, Desktop: { min: 1281, max: Infinity } }; // if no screen object it's likely to be a very old IE, so assume defult max browser screen size (Desktop) var width = window.screen ? window.screen.width : Infinity; for (var device in deviceSizes) { if (width >= deviceSizes[device].min && width <= deviceSizes[device].max) return device; } } // get screen dimensions function getScreenSize() { // if no screen object it's likely to be a very old IE var width = window.screen ? window.screen.width : 0; var height = window.screen ? window.screen.height : 0; if (width && height) { return width + "x" + height; } else { return 'Unknown'; } } // get browser viewport dimensions function getBrowserSize() { var width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); var height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); if (width && height) { return width + "x" + height; } else { return 'Unknown'; } } // get browser agent info function getBrowserInfo() { var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if (/trident/i.test(M[1])) { tem = /\brv[ :]+(\d+)/g.exec(ua) || []; return 'IE ' + (tem[1] || ''); } if (M[1] === 'Chrome') { tem = ua.match(/\b(OPR|Edge)\/(\d+)/); if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera'); } M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]); return M.join(' ') || 'Unknown'; } })();